package com.xiaotu.dao.mysql;

import com.xiaotu.entity.DirectorWorksModel;
import com.xiaotu.entity.ScreenwriterWorksModel;
import com.xiaotu.entity.TvActorsModel;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author zhangxiao
 * @create 2021-09-23 11:21
 */
public interface MysqlStarWorksMapper {

    @Delete("<script>" +
            " DELETE FROM screenwriter.tab_tv_actors " +
            "</script>")
    void clearTvActors();

    @Delete("<script>" +
            " DELETE FROM screenwriter.tab_director_works " +
            "</script>")
    void clearDirectorWorks();

    @Delete("<script>" +
            " DELETE FROM screenwriter.tab_screenwriter_works " +
            "</script>")
    void clearScreenwriterWorks();

    @Insert("<script>" +
            " INSERT INTO `screenwriter`.`tab_tv_actors`" +
            "(`tvactorid`, `starid`, `starname`, `tvid`," +
            " `tvname`, `actrole`, `worktype`, `collecttime`," +
            " `actorder`, `roleintroduction`, `rolelabel`, `episode_count`," +
            " `start_time`, `end_time`) " +
            " VALUES" +
            " <foreach collection='list' separator=',' item='v' > " +
            " (#{v.tvactorid}, #{v.starid}, #{v.starname}, #{v.tvid}," +
            " #{v.tvname}, #{v.actrole}, #{v.worktype}, #{v.collecttime}," +
            " #{v.actorder}, #{v.roleintroduction}, #{v.rolelabel}, #{v.episode_count}," +
            " #{v.start_time}, #{v.end_time}) " +
            " </foreach> " +
            "</script>")
    void batchInsertTvActors(@Param("list") List<TvActorsModel> tvActorsList);

    @Insert("<script>" +
            " INSERT INTO `screenwriter`.`tab_director_works`" +
            "(`directorworksid`, `starid`, `starname`, `tvname`," +
            " `showdate`, `actrole`, `tvdirector`, `mainactors`," +
            " `cooactors`, `worktype`, `collecttime`, `tvid`," +
            " `dirorder`, `episode_count`, `start_time`, `end_time`)" +
            " VALUES " +
            " <foreach collection='list' separator=',' item='v' > " +
            " (#{v.directorworksid}, #{v.starid}, #{v.starname}, #{v.tvname}," +
            " #{v.showdate}, #{v.actrole}, #{v.tvdirector}, #{v.mainactors}," +
            " #{v.cooactors}, #{v.worktype}, #{v.collecttime}, #{v.tvid}," +
            " #{v.dirorder}, #{v.episodeCount}, #{v.startTime}, #{v.endTime}) " +
            " </foreach> " +
            "</script>")
    void batchInsertDirectorWorks(@Param("list") List<DirectorWorksModel> directorWorksList);

    @Insert("<script>" +
            " INSERT INTO `screenwriter`.`tab_screenwriter_works`" +
            " (`screenwriterworksid`, `starid`, `starname`, `tvname`," +
            " `showdate`, `actrole`, `tvdirector`, `mainactors`," +
            " `cooactors`, `worktype`, `collecttime`, `tvid`," +
            " `episode_count`, `start_time`, `end_time`)" +
            " VALUES " +
            " <foreach collection='list' separator=',' item='v' > " +
            " (#{v.screenwriterworksid}, #{v.starid}, #{v.starname}, #{v.tvname}," +
            " #{v.showdate}, #{v.actrole}, #{v.tvdirector}, #{v.mainactors}," +
            " #{v.cooactors}, #{v.worktype}, #{v.collecttime}, #{v.tvid}," +
            " #{v.episodeCount}, #{v.startTime}, #{v.endTime}) " +
            " </foreach> " +
            "</script>")
    void batchInsertScreenwriterWorks(@Param("list") List<ScreenwriterWorksModel> screenwriterWorksList);
}
